package com.csnf.servlet;

import com.csnf.dao.BookDao;
import com.csnf.entity.Books;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/BookServlet")
public class BookServlet extends HttpServlet {
    BookDao bookDao = new BookDao();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String bookName = req.getParameter("bookName");
        try {
            List<Books> bookList = bookDao.getBooksByName(bookName);
            req.setAttribute("bookList", bookList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        req.getRequestDispatcher("bookList.jsp").forward(req, resp);
    }
}
